 
package com.mobi.Survey.lib.charts;


import android.content.Context;

import com.mobi.Survey.lib.charts.BarChart.Type;

/**
 * Utility methods for creating chart views or intents.
 */
public class ChartFactory {
	  /** The key for the chart data. */
	  public static final String CHART = "chart";

	  /** The key for the chart graphical activity title. */
	  public static final String TITLE = "title";

	  private ChartFactory() {
	    // empty
	  }


	  /**
	   * Creates a bar chart view.
	   * 
	   * @param context the context
	   * @param dataset the multiple series dataset (cannot be null)
	   * @param renderer the multiple series renderer (cannot be null)
	   * @param type the bar chart type
	   * @return a bar chart graphical view
	   * @throws IllegalArgumentException if dataset is null or renderer is null or
	   *           if the dataset and the renderer don't include the same number of
	   *           series
	   */
	  public static final GraphicalView getBarChartView(Context context,
	      XYMultipleSeriesDataset dataset, XYMultipleSeriesRenderer renderer, Type type) {
	    checkParameters(dataset, renderer);
	    XYChart chart = new BarChart(dataset, renderer, type);
	    return new GraphicalView(context, chart);
	  }



	  /**
	   * Checks the validity of the dataset and renderer parameters.
	   * 
	   * @param dataset the multiple series dataset (cannot be null)
	   * @param renderer the multiple series renderer (cannot be null)
	   * @throws IllegalArgumentException if dataset is null or renderer is null or
	   *           if the dataset and the renderer don't include the same number of
	   *           series
	   */
	  private static void checkParameters(XYMultipleSeriesDataset dataset,
	      XYMultipleSeriesRenderer renderer) {
	    if (dataset == null || renderer == null
	        || dataset.getSeriesCount() != renderer.getSeriesRendererCount()) {
	      throw new IllegalArgumentException(
	          "Dataset and renderer should be not null and should have the same number of series");
	    }
	  }


}
